package com.zygh.policeasset.mapper;

import com.zygh.policeasset.pojo.Completed;
import com.zygh.policeasset.pojo.Project;
import com.zygh.policeasset.pojo.ProjectNameType;
import com.zygh.policeasset.pojo.Section;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/* loaded from: police-asset-2.0-0.0.1-SNAPSHOT.jar:BOOT-INF/classes/com/zygh/policeasset/mapper/CompleteMapper.class */
public interface CompleteMapper {
    @Select({"<script>",
            "SELECT p.* FROM contract c " +
                    "left join completed cd on c.section_id = cd.section_id " +
                    "left join project p on c.project_no = p.project_no " +
                    "left join company cp on c.company_id = cp.id " +
                    "left join audit_flow af on c.flow_no = af.flow_no " +
                    "where af.app_status = 2 " +
                    "and cd.section_id is null " +
                    "<if test='userId != null '>" +
                    "and af.applicant = #{userId} " +
                    "</if>" +
                    "GROUP BY p.project_no ORDER BY c.id DESC " +
                    "</script>"})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "commissionNo", column = "commission_no"), @Result(property = "companyApply", column = "company_apply"), @Result(property = "capitalSource", column = "capital_source"), @Result(property = "projectBase", column = "project_base"), @Result(property = "startDatetime", column = "start_datetime")})
    List<Project> getProject(@Param("userId") Integer num);

    @Select({"select count(*) from completed t  where app_status = 1"})
    Integer findCount();

    @Select({"<script>", "select s.*,p.name as project_name from contract c left join completed cd on c.section_id = cd.section_id left join section s on c.section_id = s.id left join project p on s.project_no = p.project_no left join company cp on c.company_id = cp.id left join audit_flow af on c.flow_no = af.flow_no where af.app_status = 2 and cd.section_id is null and c.project_no = #{projectNo} <if test='userId != null '>and af.applicant = #{userId} </if>order by s.id desc </script>"})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "tenderId", column = "tender_id"), @Result(property = "sectionName", column = "section_name"), @Result(property = "sectionTime", column = "section_time"), @Result(property = "assectStatus", column = "assect_status")})
    List<Section> getAdd(@Param("projectNo") String str, @Param("userId") Integer num);

    @Insert({"insert into completed (project_no,section_id,initial_time,initial_type,progress,final_time,final_type,description,create_time,flow_no) values (#{projectNo},#{sectionId},#{initialTime},#{initialType},#{progress},#{finalTime},#{finalType},#{description},#{createTime},#{flowNo}) "})
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int add(Completed completed);

    @Select({"<script>", "select c.*,p.name as project_name,p.category,s.section_name,ct.name," +
            "cp.company_name as companyName,af.app_status,af.approval_steps_id as approvalStepsId," +
            "u.name as userName from completed c left join contract ct on c.section_id = ct.section_id " +
            "left join section s on c.section_id = s.id " +
            "left join project p on c.project_no = p.project_no " +
            "left join company cp on ct.company_id = cp.id " +
            "left join audit_flow af on c.flow_no = af.flow_no " +
            "left join user u on af.applicant = u.id " +
            "<where>" +
            "<if test='name != null and name.length &gt; 0'>and p.name like '%${name}%' </if>" +
            "<if test='category != null and category &gt; 0'>and p.category=#{category} </if>" +
            "<if test='companyId != null and companyId != 0'>and cp.id = #{companyId} </if>" +
            "<if test='time1 != null and time1.length &gt; 0 and time2 != null and time2.length &gt; 0'>and c.final_time between #{time1}  and #{time2}</if>" +
            "<if test='userId != null '> and af.applicant=#{userId} </if>" +
            "<if test=' status != null'> and af.app_status = #{status} </if>" +
            "</where>" +
            "order by c.id desc  " +
            "</script>"})
    @Results({@Result(property = "projectNo", column = "project_no"),
            @Result(property = "projectName", column = "project_name"),
            @Result(property = "sectionId", column = "section_id"),
            @Result(property = "sectionName", column = "section_name"),
            @Result(property = "contractName", column = "name"),
            @Result(property = "initialTime", column = "initial_time"),
            @Result(property = "initialType", column = "initial_type"),
            @Result(property = "finalTime", column = "final_time"),
            @Result(property = "finalType", column = "final_type"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "sectionName", column = "section_name"),
            @Result(property = "contractName", column = "name"),
            @Result(property = "flowNo", column = "flow_no"),
            @Result(property = "appStatus", column = "app_status")})
    List<Completed> findAll(@Param("name") String name,
                            @Param("status") Integer status,
                            @Param("companyId") Integer companyId,
                            @Param("time1") String time1,
                            @Param("time2") String time2,
                            @Param("category") Integer category,
                            @Param("userId") Integer userId);

    @Select({"select c.*,p.name as project_name,pr.status as status,pr.opinion as opinion from completed c left join processrecord pr on c.id = pr.project_id and pr.process_name = 'completed' left join project p on c.project_no = p.project_no where pr.status = #{status} order by c.id desc "})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "sectionId", column = "section_id"), @Result(property = "initialTime", column = "initial_time"), @Result(property = "initialType", column = "initial_type"), @Result(property = "finalTime", column = "final_time"), @Result(property = "finalType", column = "final_type"), @Result(property = "createTime", column = "create_time")})
    List<Completed> findByStatus(int i);

    @Select({"select c.*,p.name as project_name,s.section_name,ct.name,af.app_status from completed c left join contract ct on c.section_id = ct.section_id left join section s on c.section_id = s.id left join project p on c.project_no = p.project_no left join audit_flow af on c.flow_no = af.flow_no where c.project_no=#{no} order by c.id desc "})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "sectionId", column = "section_id"), @Result(property = "sectionName", column = "section_name"), @Result(property = "contractName", column = "name"), @Result(property = "initialTime", column = "initial_time"), @Result(property = "initialType", column = "initial_type"), @Result(property = "finalTime", column = "final_time"), @Result(property = "finalType", column = "final_type"), @Result(property = "createTime", column = "create_time"), @Result(property = "appStatus", column = "app_status")})
    List<Completed> findByProject(String str);

    @Select({"select c.*,p.name as project_name,s.section_name,p.category,af.app_status,af.approval_steps_id as approvalStepsId,u.name as userName,ct.name as contractName from completed c left join project p on c.project_no = p.project_no left join section s on  c.section_id = s.id left join audit_flow af on c.flow_no = af.flow_no left join user u on af.applicant = u.id left join contract ct on c.section_id = ct.section_id where c.id=#{id}"})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "sectionId", column = "section_id"), @Result(property = "sectionName", column = "section_name"), @Result(property = "initialTime", column = "initial_time"), @Result(property = "initialType", column = "initial_type"), @Result(property = "finalTime", column = "final_time"), @Result(property = "finalType", column = "final_type"), @Result(property = "createTime", column = "create_time"), @Result(property = "flowNo", column = "flow_no"), @Result(property = "appStatus", column = "app_status")})
    Completed selectById(Integer num);

    @Delete({"delete from completed where id=#{id}"})
    int delete(Integer num);

    @Update({"update completed set project_no=#{projectNo},section_id=#{sectionId},initial_time=#{initialTime},initial_type=#{initialType},progress=#{progress},final_time=#{finalTime},final_type=#{finalType},description = #{description},create_time = #{createTime} where id = #{id}"})
    int update(Completed completed);

    @Update({"update completed set app_status=#{status} where id=#{id}"})
    Integer updateStatus(int i, int i2);

    @Select({"SELECT DISTINCT p.name,p.project_no  FROM completed c LEFT JOIN  project p ON c.project_no= p.project_no left join audit_flow a on c.flow_no=a.flow_no WHERE a.app_status = 2 "})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "name")})
    List<ProjectNameType> selectBytype();

    @Select({"SELECT s.section_name  FROM completed c LEFT JOIN  section s ON c.section_id= s.id WHERE c.project_no = #{projectNo} "})
    @Results({@Result(property = "sectionName", column = "section_name")})
    List<ProjectNameType> findSectionByType(@Param("projectNo") String str);

    @Select({"<script>SELECT t.*,p.name as project_name,s.`section_name`,co.company_name  FROM completed t LEFT JOIN  project p ON t.project_no= p.project_no LEFT JOIN category c ON p.category = c.id  LEFT JOIN `section` s ON  t.`section_id`=s.`id` LEFT JOIN `contract` cs ON  cs.`project_no`=t.`project_no` and  cs.`section_id`=t.`section_id`LEFT JOIN `company` co ON  cs.`company_id`=co.`id` left join audit_flow af on t.flow_no = af.flow_no <where>af.app_status = 2 and p.category=#{id}<if test='name != null and name.length &gt; 0'> and p.name like '%${name}%' </if><if test='companyId != null and companyId != 0'> and cs.company_id = #{companyId} </if><if test='time1 != null and time2 != null and time1.length &gt; 0 and time2.length &gt; 0'> and t.create_time between #{time1} and  #{time2} </if></where></script> "})
    @Results({@Result(property = "projectNo", column = "project_no"), @Result(property = "projectName", column = "project_name"), @Result(property = "sectionId", column = "section_id"), @Result(property = "initialTime", column = "initial_time"), @Result(property = "initialType", column = "initial_type"), @Result(property = "finalTime", column = "final_time"), @Result(property = "finalType", column = "final_type"), @Result(property = "createTime", column = "create_time"), @Result(property = "sectionName", column = "section_name"), @Result(property = "companyName", column = "company_name")})
    List<Completed> toExcel(Integer num, String str, String str2, String str3, String str4);

    @Select({"select final_time from completed c where project_no=#{projectNo} and section_id = #{sectionId}"})
    String getfinalTime(@Param("projectNo") String str, @Param("sectionId") Integer num);
}